package com.micro.service.account.server.service.impl;
import com.micro.service.account.server.biz.UserBaseBiz;
import com.micro.service.account.share.dto.UserBaseDto;
import com.micro.service.account.share.dto.UserWechatDto;
import com.micro.service.account.share.service.UserBaseService;
import com.micro.service.common.dto.ResultDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lvxiucai
 * @description
 * @date 2020/4/9
 */
@RestController
@Slf4j
public class UserBaseServiceImpl implements UserBaseService {

    @Autowired
    private UserBaseBiz userBaseBiz;

    @Override
    public ResultDTO<UserBaseDto> selectByMobile(@RequestParam(value = "mobile") String mobile) {
        ResultDTO<UserBaseDto> resultDTO = new ResultDTO<>();
        if(StringUtils.isBlank(mobile)){
            return resultDTO.failure("用户手机号不能为空!");
        }
        UserBaseDto userBaseDto = userBaseBiz.selectByMobile(mobile);
        return resultDTO.success(userBaseDto);
    }

    @Override
    public UserBaseDto selectById(Long userId) {
        if(userId == null){
            return null;
        }
        return userBaseBiz.selectByUserId(userId);
    }

    @Override
    public ResultDTO<UserBaseDto> checkAndRegisterByMobile(@RequestParam(value = "mobile") String mobile,@RequestParam(value = "client_imei") String imei) {
        return null;
    }

    @Override
    public ResultDTO<Boolean> updateUserBase(UserBaseDto requestDto) {
        return null;
    }

    @Override
    public UserBaseDto checkWxExistsAndRegistry(UserWechatDto userWechatDto) {
        return null;
    }

    @Override
    public UserBaseDto loadUserByWechatOpenid(String openid) {
        return null;
    }


}
